package com.zzyl.mapper;

import com.zzyl.entity.Bed;
import com.zzyl.vo.BedVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BedMapper {

    List<BedVo> getBedsByRoomId(Long roomId);

    /**
     * 创建床位
     * @param bed
     */
    @Insert("INSERT INTO bed VALUES (null,#{bedNumber},#{bedStatus},#{sort},#{roomId},#{createTime},#{updateTime},#{createBy},#{updateBy},#{remark})")
    void addBed(Bed bed);

    /**
     * 根据ID查询床位
     * @param id
     * @return
     */
    @Select("SELECT id,bed_number,bed_status,room_id,sort FROM bed WHERE id = #{id}")
    BedVo getBedById(Long id);

    /**
     * 更新床位
     * @param bed
     */
    void update(Bed bed);

    /**
     * 删除床位
     * @param id
     */
    @Delete("DELETE FROM bed WHERE id = #{id}")
    void delete(Long id);
}

